home *** CD-ROM | disk | FTP | other *** search
- Path: prodigy.com!usenet
- From: WCME76A@prodigy.com (Shane Morrell)
- Newsgroups: comp.lang.c++
- Subject: C++ display ASCII file
- Date: 21 Jan 1996 17:17:01 GMT
- Organization: Prodigy Services Company 1-800-PRODIGY
- Distribution: world
- Message-ID: <4dtsed$309o@useneta1.news.prodigy.com>
- NNTP-Posting-Host: inugap5.news.prodigy.com
- X-Newsreader: Version 1.2
-
- I am dabbling in C++ (see code below) and need a little assistance with
- reading an ASCII file using the stream functions. This works like the
- dos TYPE command well, I want it to anyway. It does fine except it will
- not recognize the 'whitespace' in the text file. When it is displayed,
- everything is crammedtogetherlikethis. Arrrgh!
-
- Shane // shane@prodigy.com
- =========================================
-
- #include<iostream.h>
- #include<fstream.h>
-
- void main(int argc,char* argv[]) {
- if(argc<2){
- cout << "\nFilename parameter needed!";
- << endl;
- }
- else{
- ifstream src(argv[1], ios::nocreate);
- if(src) {
- char c;
-
- src >> c;
- while(!src.eof()) {
- cout << c;
- src >> c;
- }
-
- src.close();
- }
- else{ cout << argv[1]
- << " does not exist"
- << endl;
- }
- }
- }
-
-
-